<!DOCTYPE html>
<html>
<head><meta name="generator" content="Hexo 3.8.0">
  <meta charset="utf-8">

  <!-- PACE Progress Bar START -->
  
    <script src="https://raw.githubusercontent.com/HubSpot/pace/v1.0.2/pace.min.js"></script>
    <link rel="stylesheet" href="https://github.com/HubSpot/pace/raw/master/themes/orange/pace-theme-flash.css">
  
  

  <!-- PACE Progress Bar START -->

  
  <title>使用hexo搭建个人技术博客站点 | FunGa技术札记</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  
  <meta name="keywords" content="hexo">
  
  
  
  
  <meta name="description" content="很多同学都喜欢在CSDN、或者OSChina开博客；也有不少同学自己搭建网站，比如使用PHP、或者Java开发博客系统，但是需要自己购买服务器，或者使用云服务器，这样花费也不小，运维成本稍微高了一点点；也有比较折中的，比如搭建一个GitHub主页。在GitHub上可以部署静态文件，但是很明显，如果自己来写HTML传上去，写作体验比较糟糕，本文介绍使用Hexo来搭建个人博客。">
<meta name="keywords" content="hexo">
<meta property="og:type" content="article">
<meta property="og:title" content="使用Hexo搭建个人技术博客站点">
<meta property="og:url" content="funga.cn/2017/10/11/hexo/index.html">
<meta property="og:site_name" content="FunGa技术札记">
<meta property="og:description" content="很多同学都喜欢在CSDN、或者OSChina开博客；也有不少同学自己搭建网站，比如使用PHP、或者Java开发博客系统，但是需要自己购买服务器，或者使用云服务器，这样花费也不小，运维成本稍微高了一点点；也有比较折中的，比如搭建一个GitHub主页。在GitHub上可以部署静态文件，但是很明显，如果自己来写HTML传上去，写作体验比较糟糕，本文介绍使用Hexo来搭建个人博客。">
<meta property="og:locale" content="default">
<meta property="og:image" content="http://funga.oss-cn-beijing.aliyuncs.com/images/github_hexo.jpg">
<meta property="og:updated_time" content="2019-01-05T07:52:57.285Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="使用Hexo搭建个人技术博客站点">
<meta name="twitter:description" content="很多同学都喜欢在CSDN、或者OSChina开博客；也有不少同学自己搭建网站，比如使用PHP、或者Java开发博客系统，但是需要自己购买服务器，或者使用云服务器，这样花费也不小，运维成本稍微高了一点点；也有比较折中的，比如搭建一个GitHub主页。在GitHub上可以部署静态文件，但是很明显，如果自己来写HTML传上去，写作体验比较糟糕，本文介绍使用Hexo来搭建个人博客。">
<meta name="twitter:image" content="http://funga.oss-cn-beijing.aliyuncs.com/images/github_hexo.jpg">
  
    <link rel="alternate" href="/atom.xml" title="FunGa技术札记" type="application/atom+xml">
  
  <link rel="icon" href="/css/images/favicon.ico">
  
  <link href="https://fonts.googleapis.com/css?family=Open+Sans|Montserrat:700" rel="stylesheet" type="text/css">
  <link href="https://fonts.googleapis.com/css?family=Roboto:400,300,300italic,400italic" rel="stylesheet" type="text/css">
  <link href="https://cdn.bootcss.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet">
  <style type="text/css">
    @font-face{font-family:futura-pt;src:url(https://use.typekit.net/af/9749f0/00000000000000000001008f/27/l?subset_id=2&fvd=n5) format("woff2");font-weight:500;font-style:normal;}
    @font-face{font-family:futura-pt;src:url(https://use.typekit.net/af/90cf9f/000000000000000000010091/27/l?subset_id=2&fvd=n7) format("woff2");font-weight:500;font-style:normal;}
    @font-face{font-family:futura-pt;src:url(https://use.typekit.net/af/8a5494/000000000000000000013365/27/l?subset_id=2&fvd=n4) format("woff2");font-weight:lighter;font-style:normal;}
    @font-face{font-family:futura-pt;src:url(https://use.typekit.net/af/d337d8/000000000000000000010095/27/l?subset_id=2&fvd=i4) format("woff2");font-weight:400;font-style:italic;}</style>
    
  <link rel="stylesheet" id="athemes-headings-fonts-css" href="//fonts.googleapis.com/css?family=Yanone+Kaffeesatz%3A200%2C300%2C400%2C700&amp;ver=4.6.1" type="text/css" media="all">
  <link rel="stylesheet" href="/css/style.css">

  <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>

  <!-- Bootstrap core CSS -->
  <link rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootstrap/3.0.2/css/bootstrap.min.css">
  <link rel="stylesheet" href="/css/hiero.css">
  <link rel="stylesheet" href="/css/glyphs.css">
  
    <link rel="stylesheet" href="/css/vdonate.css">
  

  <!-- Custom CSS -->
  <link rel="stylesheet" href="/css/my.css">
  <!-- Google Adsense -->
  
<link rel="stylesheet" href="/css/prism-tomorrow.css" type="text/css"></head>
</html>
<script>
var themeMenus = {};

  themeMenus["/"] = "Home"; 

  themeMenus["/archives"] = "Archives"; 

  themeMenus["/categories"] = "Categories"; 

  themeMenus["/tags"] = "Tags"; 

  themeMenus["/about"] = "About"; 

</script>


  <body data-spy="scroll" data-target="#toc" data-offset="50">


  <header id="allheader" class="site-header" role="banner">
  <div class="clearfix container">
      <div class="site-branding">

          <h1 class="site-title">
            
              <a href="/" title="FunGa技术札记" rel="home"> FunGa技术札记 </a>
            
          </h1>

          
            
          <nav id="main-navigation" class="main-navigation" role="navigation">
            <a class="nav-open">Menu</a>
            <a class="nav-close">Close</a>
            <div class="clearfix sf-menu">

              <ul id="main-nav" class="nmenu sf-js-enabled">
                    
                      <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-home menu-item-1663"> <a class="" href="/">Home</a> </li>
                    
                      <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-home menu-item-1663"> <a class="" href="/archives">Archives</a> </li>
                    
                      <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-home menu-item-1663"> <a class="" href="/categories">Categories</a> </li>
                    
                      <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-home menu-item-1663"> <a class="" href="/tags">Tags</a> </li>
                    
                      <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-home menu-item-1663"> <a class="" href="/about">About</a> </li>
                    
              </ul>
            </div>
          </nav>


      </div>
  </div>
</header>




  <div id="container">
    <div id="wrap">
            
      <div id="content" class="outer">
        
          <section id="main" style="float:none;"><article id="post-hexo" style="width: 66%; float:left;" class="article article-type-post" itemscope="" itemprop="blogPost">
  <div id="articleInner" class="clearfix post-1016 post type-post status-publish format-standard has-post-thumbnail hentry category-template-2 category-uncategorized tag-codex tag-edge-case tag-featured-image tag-image tag-template">
    
<div class="article-gallery">
  <div class="article-gallery-photos">
    
      <a class="article-gallery-img fancybox" href="http://funga.oss-cn-beijing.aliyuncs.com/images/github_hexo.jpg" rel="gallery_cjqujn6vs00058zvnts1uidai">
        <img src="http://funga.oss-cn-beijing.aliyuncs.com/images/github_hexo.jpg" itemprop="image">
      </a>
    
  </div>
</div>

    
      <header class="article-header">
        
  
    <h1 class="thumb" itemprop="name">
      使用Hexo搭建个人技术博客站点
    </h1>
  

      </header>
    
    <div class="article-meta">
      
	Posted on <a href="/2017/10/11/hexo/" class="article-date">
	  <time datetime="2017-10-11T08:23:41.000Z" itemprop="datePublished">October 11, 2017</time>
	</a>

      
	<span id="busuanzi_container_page_pv">
	  本文总阅读量<span id="busuanzi_value_page_pv"></span>次
	</span>

    </div>
    <div class="article-entry" itemprop="articleBody">
      
        <blockquote>
<p>很多同学都喜欢在CSDN、或者OSChina开博客；也有不少同学自己搭建网站，比如使用PHP、或者Java开发博客系统，但是需要自己购买服务器，或者使用云服务器，这样花费也不小，运维成本稍微高了一点点；也有比较折中的，比如搭建一个GitHub主页。在GitHub上可以部署静态文件，但是很明显，如果自己来写HTML传上去，写作体验比较糟糕，本文介绍使用Hexo来搭建个人博客。<br><a id="more"></a></p>
</blockquote>
<h2 id="环境搭建"><a href="#环境搭建" class="headerlink" title="环境搭建"></a>环境搭建</h2><p><a href="https://hexo.io/">Hexo官网</a>有Hexo的详细介绍，我们直接说说操作的流程和一些细节：</p>
<p>环境要求:</p>
<ul>
<li>Git</li>
<li>Node.js</li>
</ul>
<p>安装Hexo：</p>
<pre class=" language-shell"><code class="language-shell">npm install -g hexo-cli
</code></pre>
<h2 id="建站"><a href="#建站" class="headerlink" title="建站"></a>建站</h2><p>安装 Hexo 完成后，请执行下列命令，Hexo 将会在指定文件夹中新建所需要的文件</p>
<pre class=" language-shell"><code class="language-shell">hexo init blog 
cd blog
npm install
hexo server
</code></pre>
<p>执行完最后一条命令后访问：<a href="http://localhost:4000/">http://localhost:4000/</a> 即可访问网站。</p>
<h2 id="配置"><a href="#配置" class="headerlink" title="配置"></a>配置</h2><h3 id="主题配置"><a href="#主题配置" class="headerlink" title="主题配置"></a>主题配置</h3><p>本站使用的是主题是Hiero，先从Github下载到本地：<a href="https://github.com/iTimeTraveler/hexo-theme-hiero">https://github.com/iTimeTraveler/hexo-theme-hiero</a></p>
<p>将主题中的以下文件、文件夹拷贝至项目的themes/hiero目录下：</p>
<pre class=" language-text"><code class="language-text">languages
layout
scripts
source
_config.yml
</code></pre>
<p>修改项目的_config.yml：</p>
<pre class=" language-text"><code class="language-text">theme: hiero
</code></pre>
<p>修改主题的_config.yml：</p>
<ul>
<li>修改 social</li>
<li>修改 donate</li>
</ul>
<h3 id="分类、标签、关于"><a href="#分类、标签、关于" class="headerlink" title="分类、标签、关于"></a>分类、标签、关于</h3><p>虽然有分类、标签和关于的菜单，但是目前是没有的，我们加上相应的页面：</p>
<pre class=" language-shell"><code class="language-shell">hexo new page categories
hexo new page tags
hexo new page about
</code></pre>
<p>执行之后会在source目录下出现三个文件夹，文件夹下对应都有个index.md。<br>分别加上如下配置：</p>
<pre class=" language-text"><code class="language-text">---
title: categories
date: 2018-12-14 15:38:07
type: "categories"
layout: "categories"
---
</code></pre>
<pre class=" language-text"><code class="language-text">---
title: tags
date: 2018-12-14 15:38:01
type: "tags"
layout: "tags"
---
</code></pre>
<pre class=" language-text"><code class="language-text">---
title: about
date: 2018-12-14 14:37:57
type: "about"
layout: "about"
---
</code></pre>
<h3 id="搜索生效"><a href="#搜索生效" class="headerlink" title="搜索生效"></a>搜索生效</h3><pre class=" language-shell"><code class="language-shell">npm install hexo-generator-json-content --save
</code></pre>
<h2 id="GitHub主页"><a href="#GitHub主页" class="headerlink" title="GitHub主页"></a>GitHub主页</h2><ul>
<li>在GitHub上创建一个项目，名称为{xxx}.github.com,比如我的为funga.github.com。</li>
<li>本地电脑配置好SSHKEY</li>
<li>安装部署依赖<pre class=" language-shell"><code class="language-shell">npm install hexo-deployer-git --save
</code></pre>
</li>
<li>部署<pre class=" language-shell"><code class="language-shell">hexo g
hexo d
</code></pre>
访问：http://{xxx}.github.io</li>
</ul>
<h2 id="写文章"><a href="#写文章" class="headerlink" title="写文章"></a>写文章</h2><p>创建一篇文章，会在source下创建一个redis.md文件，使用MarkDown语法进行写作即可。</p>
<pre class=" language-shell"><code class="language-shell">hexo new redis
</code></pre>
<h3 id="文章配置"><a href="#文章配置" class="headerlink" title="文章配置"></a>文章配置</h3><table>
<thead>
<tr>
<th>参数</th>
<th style="text-align:center">描述</th>
<th style="text-align:right">默认值</th>
</tr>
</thead>
<tbody>
<tr>
<td>layout</td>
<td style="text-align:center">布局</td>
<td style="text-align:right"></td>
</tr>
<tr>
<td>title</td>
<td style="text-align:center">标题</td>
<td style="text-align:right"></td>
</tr>
<tr>
<td>date</td>
<td style="text-align:center">建立日期</td>
<td style="text-align:right">文件建立日期</td>
</tr>
<tr>
<td>updated</td>
<td style="text-align:center">更新日期</td>
<td style="text-align:right">文件更新日期</td>
</tr>
<tr>
<td>comments</td>
<td style="text-align:center">开启文章的评论功能</td>
<td style="text-align:right">true</td>
</tr>
<tr>
<td>tags</td>
<td style="text-align:center">标签（不适用于分页）</td>
<td style="text-align:right"></td>
</tr>
<tr>
<td>categories</td>
<td style="text-align:center">分类（不适用于分页）</td>
<td style="text-align:right"></td>
</tr>
<tr>
<td>permalink</td>
<td style="text-align:center">覆盖文章网址</td>
<td style="text-align:right"></td>
</tr>
</tbody>
</table>
<h2 id="域名配置"><a href="#域名配置" class="headerlink" title="域名配置"></a>域名配置</h2><p>可以注册一个域名CNAME到{xxx}.github.io</p>

      
    </div>
    <footer class="entry-meta entry-footer">
      
	<span class="ico-folder"></span>
    <a class="article-category-link" href="/categories/其它分类/">其它分类</a>

      
  <span class="ico-tags"></span>
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/hexo/">hexo</a></li></ul>

      
        <div id="donation_div"></div>

<script src="/js/vdonate.js"></script>
<script>
var a = new Donate({
  title: '如果觉得我的文章对您有用，请随意打赏。您的支持将鼓励我继续创作!', // 可选参数，打赏标题
  btnText: 'Donate', // 可选参数，打赏按钮文字
  el: document.getElementById('donation_div'),
  wechatImage: 'https://funga.oss-cn-beijing.aliyuncs.com/config/wechat_pay_code.jpg',
  alipayImage: 'https://funga.oss-cn-beijing.aliyuncs.com/config/alipay_code.png'
});
</script>
      
            
      
        <!--PC版-->
<div id="SOHUCS"></div>
<!-- <script charset="utf-8" type="text/javascript" src="https://changyan.sohu.com/upload/changyan.js" ></script> -->
<script charset="utf-8" type="text/javascript" src="https://funga.oss-cn-beijing.aliyuncs.com/static/changyan.js"></script>
<script type="text/javascript">
window.changyan.api.config({
appid: 'cyrV0wIGI',
conf: 'prod_3d29a99dcddb3782e98f1fa951b9868f'
});
</script>
      
    </footer>
  </div>
  
    
<nav id="article-nav">
  
    <a href="/2017/10/20/sb-e/" id="article-nav-newer" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Newer</strong>
      <div class="article-nav-title">
        
          基于SpringBoot的Java Web项目全局异常捕获
        
      </div>
    </a>
  
  
</nav>

  
</article>

<!-- Table of Contents -->

  <aside id="sidebar">
    <div id="toc" class="toc-article" style="overflow-y: scroll; max-width: 28%;">
    <strong class="toc-title">Contents</strong>
    
      <ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#环境搭建"><span class="nav-number">1.</span> <span class="nav-text">环境搭建</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#建站"><span class="nav-number">2.</span> <span class="nav-text">建站</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#配置"><span class="nav-number">3.</span> <span class="nav-text">配置</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#主题配置"><span class="nav-number">3.1.</span> <span class="nav-text">主题配置</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#分类、标签、关于"><span class="nav-number">3.2.</span> <span class="nav-text">分类、标签、关于</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#搜索生效"><span class="nav-number">3.3.</span> <span class="nav-text">搜索生效</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#GitHub主页"><span class="nav-number">4.</span> <span class="nav-text">GitHub主页</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#写文章"><span class="nav-number">5.</span> <span class="nav-text">写文章</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#文章配置"><span class="nav-number">5.1.</span> <span class="nav-text">文章配置</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#域名配置"><span class="nav-number">6.</span> <span class="nav-text">域名配置</span></a></li></ol>
    
    </div>
  </aside>
</section>
        
      </div>
      <footer id="footer" class="site-footer">
  

  <div class="clearfix container">
      <div class="site-info">
	      &copy; 2019 FunGa技术札记 All Rights Reserved.
          
            <span id="busuanzi_container_site_uv">
              本站访客数<span id="busuanzi_value_site_uv"></span>人次  
              本站总访问量<span id="busuanzi_value_site_pv"></span>次
            </span>
          
      </div>
      <div class="site-credit">
        Theme by <a href="https://github.com/iTimeTraveler/hexo-theme-hiero" target="_blank">hiero</a>
      </div>
  </div>
</footer>


<!-- min height -->

<script>
    var contentdiv = document.getElementById("content");

    contentdiv.style.minHeight = document.body.offsetHeight - document.getElementById("allheader").offsetHeight - document.getElementById("footer").offsetHeight + "px";
</script>

<!-- Custome JS -->
<script src="/js/my.js"></script>
    </div>
    <!-- <nav id="mobile-nav">
  
    <a href="/" class="mobile-nav-link">Home</a>
  
    <a href="/archives" class="mobile-nav-link">Archives</a>
  
    <a href="/categories" class="mobile-nav-link">Categories</a>
  
    <a href="/tags" class="mobile-nav-link">Tags</a>
  
    <a href="/about" class="mobile-nav-link">About</a>
  
</nav> -->
    

<!-- mathjax config similar to math.stackexchange -->

<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    tex2jax: {
      inlineMath: [ ['$','$'], ["\\(","\\)"] ],
      processEscapes: true
    }
  });
</script>

<script type="text/x-mathjax-config">
    MathJax.Hub.Config({
      tex2jax: {
        skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
      }
    });
</script>

<script type="text/x-mathjax-config">
    MathJax.Hub.Queue(function() {
        var all = MathJax.Hub.getAllJax(), i;
        for(i=0; i < all.length; i += 1) {
            all[i].SourceElement().parentNode.className += ' has-jax';
        }
    });
</script>

<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.4/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>



  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fancybox/2.1.5/jquery.fancybox.min.css">
  <script src="https://cdnjs.cloudflare.com/ajax/libs/fancybox/2.1.5/jquery.fancybox.min.js"></script>


<script src="/js/scripts.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="/js/main.js"></script>







  <div style="display: none;">
    <script src="https://s95.cnzz.com/z_stat.php?id=1260716016&web_id=1260716016" language="JavaScript"></script>
  </div>



	<script async src="https://dnqof95d40fo6.cloudfront.net/atw7f8.js">
	</script>






  </div>

  <a id="rocket" href="#top" class=""></a>
  <script type="text/javascript" src="/js/totop.js" async=""></script>
</body>
</html>
